package com.lamda.zhekou.timer;

import com.lamda.zhekou.manager.ServerHostManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Component
@Configurable
@EnableScheduling
public class ScheduledTasks {

    public static final Logger LOGGER = Logger.getLogger(ScheduledTasks.class);

    @Autowired
    private ServerHostManager serverHostManager;

    /**
     * 10分钟定时检查一次用户的vps到期情况
     */
    @Scheduled(fixedRate = 1000 * 60*10, initialDelay = 1000 * 10)
   // @Scheduled(fixedRate = 1000 * 60, initialDelay = 1000 * 10)
    public void checkWarning() {
        //统计服务器到期情况
        this.serverHostManager.checkWarning();
    }

    /**
     * 1分钟定时检查一次用户的vps过期期情况
     */
    @Scheduled(fixedRate = 1000 * 60*2, initialDelay = 1000 * 10)
    // @Scheduled(fixedRate = 1000 * 60, initialDelay = 1000 * 10)
    public void checkExpired() {
        //统计服务器到期情况
        this.serverHostManager.checkExpired();
    }

}